﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace WoWConnecter
{
    [AttributeUsage(AttributeTargets.Method)]
    public class PacketMethod : Attribute
    {
        public int PacketId { get; protected set; }
        public bool HandledIngame { get; protected set; }
        public object Method { get; set; }
        public object Object { get; set; }
        public PacketType Type { get; set; }

        public PacketMethod(object packetId)
        {
            PacketId = (int)packetId;
            HandledIngame = false;
        }

        public PacketMethod(RealmServerOpCode opcode, bool ingame)
        {
            PacketId = (int)opcode;
            HandledIngame = ingame;
        }

        public void Invoke(RealmPacketIn packet)
        {
            if (Method is RealmPacketMethod)
            {
                (Method as RealmPacketMethod)(packet);
            }
        }

        public void Invoke(AuthPacketIn packet)
        {
            if (Method is AuthPacketMethod)
            {
                (Method as AuthPacketMethod)(packet);
            }
        }
    }
}
